package com.jump.jar.jump_jar;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.File;
import java.io.FileWriter;


@SpringBootApplication
public class JumpJarApplication {

    public static void loadConfig() throws Exception {
        if (!new File("./config.json").exists()) {
            saveConfig();
        }
    }

    public static void saveConfig() {
        try (FileWriter file = new FileWriter("./config.json")) {
            file.write("{\n" +
                    "  \"1813533250\": {\n" +
                    "    \"PRIVATE_KEY\": \"Yym6ICytRZiCo4A\",\n" +
                    "    \"EXPIRED_TIME_SEC\": \"180\"\n" +
                    "  },\n" +
                    "  \"123456\": {\n" +
                    "    \"PRIVATE_KEY\": \"Yym6ICytRZiCo4A\",\n" +
                    "    \"EXPIRED_TIME_SEC\": \"180\"\n" +
                    "  }\n" +
                    "}");
        } catch (Throwable e) {
            System.out.println("save config failed.");
        }
    }

    public static void main(String[] args) throws Exception {
        loadConfig();
        SpringApplication.run(JumpJarApplication.class, args);
    }


}
